home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
misc
/
amag
/
AM9410_2.lha
/
Haufenweise
/
Programme
/
AllocateTest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-11
|
1KB
|
55 lines
#include "AllocSupport.h"
#include <clib/dos_protos.h>
#define BLOCKGROESSE 1000000
#define BLOCKANZAHL 100000
__far APTR memblocks[BLOCKANZAHL];
int main(int argc, char *agrv[])
{
struct MemHeader *mh = 0L;
register int i = 0,j;
register int p;
Printf("Freier Speicher: %ld\n",AvailMem(MEMF_ANY));
if (mh = AllocMemHeader(BLOCKGROESSE,MEMF_FAST))
{
Printf("Freier Speicher: %ld\n",AvailMem(MEMF_ANY));
/* der Block ist alloziert */
i = 0;
while (i < BLOCKANZAHL)
{
if (i % 50 == 0) Printf("%5ld\r",i);
if (!(memblocks[i++] = AllocateVec(mh,16)))
{ break; }
}
// Printf("Frei ist: %ld\n", mh->mh_Free); Delay(50L);
Printf("%5ld\n",i);
/* nur zu Testzwecken einzeln freigeben */
//j = i-2; i-= 2;
//while (i >= 0)
i = 0;
while (i < BLOCKANZAHL)
{
if (i % 50 == 0) Printf("%5ld\r",i);
//p = (i-- * 5437) % j;
if (memblocks[i] != 0)
{ DeallocateVec(mh,memblocks[i++]);
// memblocks[p] = 0;
}
else
{ break; }
}
Printf("%5ld\n",i);
// */
FreeMemHeader(mh);
}
Printf("Freier Speicher: %ld\n",AvailMem(MEMF_ANY));
return 0L;
}